package com.hahaliu.hahaliu.controller.user;

import com.hahaliu.hahaliu.common.result.Result;
import com.hahaliu.hahaliu.common.context.CurrentUser;
import com.hahaliu.hahaliu.pojo.entity.MsgUnread;
import com.hahaliu.hahaliu.service.message.MsgUnreadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/message")
@Api(tags = "用户端消息相关接口")
@Slf4j
public class MessageController {
	@Autowired
	private CurrentUser currentUser;
	@Autowired
	private MsgUnreadService msgUnreadService;

	@GetMapping("/unread/all")
	@ApiOperation("获取当前用户全部未读消息数量")
	public Result<MsgUnread> getMsgUnread() {
		Integer uid = currentUser.getUserId();
		return Result.success(msgUnreadService.getUnread(uid));
	}

	@PostMapping("/unread/clear")
	@ApiOperation("清除某一列的未读消息提示")
	public void clearUnread(@RequestParam("column") String column) {
		Integer uid = currentUser.getUserId();
		msgUnreadService.clearUnread(uid, column);
	}


}
